<?php
class lib_company_order_log extends lib_base{
	public $table_name = "qc_company_order_log";
    public $pk = "id";

    public function add_log($order_id,$data){
		$order = D('company_order')->get_info($order_id);

		$msg = array(
    		'1'=>'发布了订单',
    		'2'=>'派送了订单',
    		'3'=>'接受了订单',
    		'4'=>'订单已完成',
    		'5'=>'订单已确认',
    		'6'=>'评价了订单',
    		'7'=>'结算了订单',
    		'99'=>'取消了订单',
    	);
		
    	$intro['msg'] = $msg[$order['order_status']];
        if($order['order_status'] > 1){
            // if($data['photo']) $intro['photo'] = joinStr($data['photo']);
			if($data['photo']){
				$intro['photo'] = json_decode($data['photo'],true);
			} 
            if($data['intro']) $intro['intro'] = $data['intro'];
		}
		
    	if($order){
	        $arrBase = array(
				'company_id' =>$order['company_id'],
	        	'order_id' =>$order_id,
                'device_id' =>$order['device_id'],
				'intro' =>serialize($intro),
				'order_status' =>$order['order_status'],
				'status' =>1,
				'add_time'=>date('Y-m-d H:i:s'),
			);
			return $this->add($arrBase);
		}
		
    }
}